Ext.require(['Ext.grid.*',
    'Ext.layout.container.HBox',
    'Ext.layout.container.VBox',
    'Siga.model.inscripcion.MMateriasCursar',
    'Siga.view.inscripcion.VGridMateriasCursar',
    'Siga.view.inscripcion.VGridMateriasInscritas',
    'Siga.view.inscripcion.VGridSeccionesDisponibles',
    'Siga.view.inscripcion.VDetalleMateria',
]);

var fieldsetDetallesMateria = Ext.create('Ext.form.FieldSet', {
    title: 'Materia Seleccionada',
    defaultType: 'textfield',
    layout: 'anchor',
    margin: '0 5 6 0',
    height: 150,
    flex: 8,
    id: 'detallesID',
    defaults: {
        anchor: '100%',
        margin: '4 0 4 0',
    },
    items: [{
            xtype: 'fieldcontainer',
            fieldLabel: 'Materia',
            layout: 'hbox',
            cls: 'colorize',
            combineErrors: true,
            defaultType: 'textfield',
            defaults: {
                hideLabel: 'true',
                margin: '1 0 1 0',
                width: '100%',
                height: 20,
            },
            items: [{
                    name: 'txtMateria',
                    id: 'txtMateriaID',
                    emptyText: 'Nombre de la materia',
                    allowBlank: false,
                    disabled: true
                }]
        }, {
            xtype: 'container',
            layout: 'hbox',
            defaultType: 'textfield',
            defaults: {
                labelAlign: 'right',
            },
            items: [{
                    labelAlign: 'left',
                    fieldLabel: 'Trayecto',
                    name: 'txtTrayecto',
                    id: 'txtTrayectoID',
                    vtype: 'trayecto',
                    flex: 1,
                    allowBlank: false,
                    disabled: true,
                }, {
                    fieldLabel: 'Turno',
                    name: 'txtTurno',
                    id: 'txtTurnoID',
                    vtype: 'turno',
                    flex: 1,
                    allowBlank: false,
                    disabled: true
                }, {
                    fieldLabel: 'Periodo',
                    name: 'periodo',
                    vtype: 'periodo',
                    flex: 1,
                    allowBlank: false,
                    disabled: true
                }, {
                    fieldLabel: 'Nº U.Creditos',
                    name: 'creditos',
                    vtype: 'creditos',
                    flex: 1,
                    allowBlank: false,
                    disabled: true
                }]
        }, {
            xtype: 'fieldcontainer',
            fieldLabel: 'Horario',
            layout: 'vbox',
            combineErrors: true,
            defaultType: 'textfield',
            defaults: {
                hideLabel: 'true',
                width: '100%',
                height: 60,
            },
            items: [{
                    xtype: 'textarea',
                    hideLabel: true,
                    name: 'horario',
                    flex: 1,
                    disabled: true
                }]
        }]
});


var buttonRetirarMaterias = Ext.create('Ext.Container', {
    requires: [
        'Ext.layout.container.Center'
    ],
    xtype: 'layout-center',
    flex: 2,
    layout: {
        type: 'table',
        columns: 1,
    },
    items: [{
            xtype: 'button',
            iconCls: 'icon-delete',
            text: 'Eliminar Unidad Curricular',
            scale: 'medium',
            margin: '10 0 10 0',
        }
//        {
//            xtype: 'button',
//            iconCls: 'icon-reset',
//            text: 'Cancelar Inscripción',
//            scale: 'medium',
//            margin: '10 0 10 0',
//        }
    ]
});

Ext.define('Siga.view.inscripcion.VInscripcion', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.inscripcion',
    xtype: 'form-inscripcion',
    frame: true,
    fieldDefaults: {
        labelAlign: 'right',
        labelWidth: 80,
    },
    items: [{
            xtype: 'tabpanel',
            reference: 'tabpanel',
            border: false,
            defaults: {
                bodyPadding: 10,
                autoScroll: true,
                border: false
            },
            items: [{
                    title: 'Inscripción',
                    icon: null,
                    glyph: 42,
                    xtype: 'container',
                    cls: 'colorize',
                    combineErrors: true,
                    items: [{
                            title: 'Inscripción',
                            icon: null,
                            glyph: 42,
                            xtype: 'container',
                            layout: {
                                type: 'hbox',
                                pack: 'start',
                                align: 'stretch'
                            },
                            cls: 'colorize',
                            combineErrors: true,
                            items: [{
                                    id: 'appcentro',
                                    flex: 7.5,
                                    xtype: 'gridMateriasCursar',
                                    tabBar: {ui: 'default'},
                                    title: 'MATERIAS A CURSAR',
                                    region: 'center',
                                    margin: '0 0 0 0',
                                }, {
                                    id: 'appcentroa',
                                    flex: 1.5,
                                    xtype: 'gridSeccionesDisponibles',
                                    tabBar: {ui: 'default'},
                                    title: 'SECCIONES DISPONIBLES',
                                    region: 'center',
                                    margin: '0 0 0 0',
                                }, {
                                    xtype: 'button',
                                    text: 'Inscribir',
                                    id: 'btn-inscribir',
                                    name: 'inscribir',
                                    action: 'inscribir',
                                }]
                        },
                        {
                            xtype: 'container',
                            fieldLabel: 'SSS',
                            layout: {
                                type: 'hbox',
                                pack: 'start',
                                align: 'stretch'
                            },
                            combineErrors: true,
                            items: [
//                                {
//                                    id: 'detalles',
//                                    xtype: 'detalleMateria',
//                                }, 
                            ]
                        },
                        {
                            title: 'Inscripción',
                            icon: null,
                            glyph: 42,
                            xtype: 'container',
                            layout: {
                                type: 'hbox',
                                pack: 'start',
                                align: 'stretch'
                            },
                            cls: 'colorize',
                            combineErrors: true,
                            items: [{
                                    id: 'appcentrob',
                                    xtype: 'gridMateriasInscritas',
                                    tabBar: {ui: 'default'},
                                    title: 'MATERIAS INSCRITAS',
                                    region: 'center',
                                    margin: '0 0 0 0',
                                }]
                        }]
                },
                {
                    title: 'Ver Horarios',
                    iconCls: 'icon-grid',
                    glyph: 70,
                }
            ]
        }],
    buttons: [buttonRetirarMaterias, {
            text: 'Imprimir Planilla',
            width: 200,
            scope: this,
            handler: this.onCompleteClick,
            action: 'imprimir',
        }]
});